#include <iostream>
#include <fstream>
#include "polygon.h"

int main()
{
//    std::ifstream in("a.in");
//    std::ofstream out("a.out");

    polygon poly;
    std::cin >> poly;
    size_t n;
    std::cin >> n;
    for (size_t i = 0; i < n; i++)
    {
        point p;
        std::cin >> p;
        std::cout << poly.is_inside(p) << "\n";
    }

 /*   simple_polygon sp;
    std::cin >> sp;
    polygon poly = polygon(sp);

    size_t m;
    in >> m;

    point p;
    for (size_t i = 0; i < m; i++)
    {
        in >> p;
        out << (poly.is_inside_convex_polygon(p) == -1 ? "NO" : "YES") << '\n';
    }
 */
    return 0;
}
